package log

import "context"

var (
	defaultLogger ILogger
)

func GetLogger() ILogger {
	return defaultLogger
}

func OpenLog(app string, opts ...Option) {
	defaultLogger = New(app, opts...)
}

func DebugWithContext(ctx context.Context, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.DebugWithContext(ctx, a...)
	}
}

func DebugfWithContext(ctx context.Context, format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.DebugfWithContext(ctx, format, a...)
	}
}
func InfoWithContext(ctx context.Context, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.InfoWithContext(ctx, a...)
	}
}

func InfofWithContext(ctx context.Context, format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.InfofWithContext(ctx, format, a...)
	}
}
func WarnWithContext(ctx context.Context, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.WarnWithContext(ctx, a...)
	}
}

func WarnfWithContext(ctx context.Context, format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.WarnfWithContext(ctx, format, a...)
	}
}
func ErrorWithContext(ctx context.Context, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.ErrorWithContext(ctx, a...)
	}
}

func ErrorfWithContext(ctx context.Context, format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.ErrorfWithContext(ctx, format, a...)
	}
}

func PanicWithContext(ctx context.Context, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.PanicWithContext(ctx, a...)
	}
}

func PanicfWithContext(ctx context.Context, format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.PanicfWithContext(ctx, format, a...)
	}
}

func FatalWithContext(ctx context.Context, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.FatalWithContext(ctx, a...)
	}
}

func FatalfWithContext(ctx context.Context, format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.FatalfWithContext(ctx, format, a...)
	}
}

func DebugWithTraceID(traceID string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.DebugWithTraceID(traceID, a...)
	}
}

func DebugfWithTraceID(traceID string, format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.DebugfWithTraceID(traceID, format, a...)
	}
}

func InfoWithTraceID(traceID string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.InfoWithTraceID(traceID, a...)
	}
}

func InfofWithTraceID(traceID string, format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.InfofWithTraceID(traceID, format, a...)
	}
}

func WarnWithTraceID(traceID string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.WarnWithTraceID(traceID, a...)
	}
}

func WarnfWithTraceID(traceID string, format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.WarnfWithTraceID(traceID, format, a...)
	}
}

func ErrorWithTraceID(traceID string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.ErrorWithTraceID(traceID, a...)
	}
}

func ErrorfWithTraceID(traceID string, format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.ErrorfWithTraceID(traceID, format, a...)
	}
}

func PanicWithTraceID(traceID string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.PanicWithTraceID(traceID, a...)
	}
}

func PanicfWithTraceID(traceID string, format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.PanicfWithTraceID(traceID, format, a...)
	}
}

func FatalWithTraceID(traceID string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.FatalWithTraceID(traceID, a...)
	}
}

func FatalfWithTraceID(traceID string, format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.FatalfWithTraceID(traceID, format, a...)
	}
}

func Debug(a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.Debug(a...)
	}
}

func Debugf(format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.Debugf(format, a...)
	}
}

func Info(a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.Info(a...)
	}
}

func Infof(format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.Infof(format, a...)
	}
}

func Warn(a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.Warn(a...)
	}
}

func Warnf(format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.Warnf(format, a...)
	}
}

func Error(a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.Error(a...)
	}
}

func Errorf(format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.Errorf(format, a...)
	}
}

func Panic(a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.Panic(a...)
	}
}

func Panicf(format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.Panicf(format, a...)
	}
}

func Fatal(a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.Fatal(a...)
	}
}

func Fatalf(format string, a ...interface{}) {
	if defaultLogger != nil {
		defaultLogger.Fatalf(format, a...)
	}
}
